package com.pfzy.ui.activity.pick;

import android.util.Log;

import com.pfzy.ui.utils.DateUtils;

import java.util.Calendar;

public class PickerUtils {
    public static DateInfo getDayText(int delay, String name) {
        Calendar calenStart = DateUtils.getCalendarDayStart(delay);
        Calendar calenEnd = DateUtils.getCalendarDayEnd(delay);
        StringBuffer dateStr = new StringBuffer();
        int year = calenStart.get(Calendar.YEAR);
        dateStr.append(year + "-");

        int month = calenStart.get(Calendar.MONTH) + 1;
        if (month < 10) {
            dateStr.append("0" + month);
        } else {
            dateStr.append("" + month);
        }

        int day = calenStart.get(Calendar.DAY_OF_MONTH);
        if (day < 10) {
            dateStr.append("-0" + day);
        } else {
            dateStr.append("-" + day);
        }

        long startTime = calenStart.getTimeInMillis();
        long endTime = calenEnd.getTimeInMillis();
        Log.e("初始化当天时间", "开始："+startTime+"， 结束："+endTime);
        return new DateInfo(name, startTime, endTime, dateStr.toString());
    }

    public static DateInfo getDayText(int delay) {
        Calendar calenStart = DateUtils.getCalendarDayStart(delay);
        Calendar calenEnd = DateUtils.getCalendarDayEnd(delay);

        StringBuffer str = new StringBuffer();
        StringBuffer dateStr = new StringBuffer();

        int year = calenStart.get(Calendar.YEAR);
        dateStr.append(year + "-");

        int month = calenStart.get(Calendar.MONTH) + 1;
        if (month < 10) {
            str.append("0" + month + "月");
            dateStr.append("0" + month + "-");
        } else {
            str.append(month + "月");
            dateStr.append(month + "-");
        }

        int day = calenStart.get(Calendar.DAY_OF_MONTH);
        if (day < 10) {
            str.append("0" + day + "日");
            dateStr.append("0" + day);
        } else {
            str.append(day + "日");
            dateStr.append(day);
        }

        long startTime = calenStart.getTimeInMillis();
        long endTime = calenEnd.getTimeInMillis();
        Log.e("初始化当天时间", "开始："+startTime+"， 结束："+endTime);

        return new DateInfo(str.toString(), startTime, endTime, dateStr.toString());
    }
}
